
import {member as memberApi} from '@/http';

export default {
    namespaced: true,
    state: {
        loading : false,
        data : []
    },
    mutations: {
        loading(state,e){
            state.loading = e;
        },
        data(state,e){
            state.data = e;
        }
    },
    actions: {
        initdata({commit,state}){
            commit('loading',true);
            memberApi.post('coupon/vip/wxlist').then(res => {
                if(!res.data.code){
                    commit('data',res.data.data);
                }
                commit('loading',false);
            }).catch(err => {
              this.$message({
                message: '登陆过期，请重新登陆！',
                type: 'error'
              });
              localStorage.removeItem('user');
              localStorage.removeItem('company');
              localStorage.removeItem('api_token');
              localStorage.removeItem('refresh_token');
              location.reload()
            })
        }
    },
    getters : {
        data : state => type => {
            if(type == 1){
                return state.data.filter(i => i.status == 1 || i.status == 2)
            }else{
                return state.data.filter(i => i.status == 3)
            }
        }
    },
    modules: {

    }
};
